package part3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * J5Ex12SortStrings 
 *   Example of use of Collections.sort for Strings
 *   
 * @author tony
 */

public class J5Ex12SortStrings {

	public static void main(String[] args){
		List<String> list = new ArrayList<String>();
		list.add("Hello");
		list.add( "123" );
		list.add( "19" );
		list.add( "Goodbye" );
		/*
		 * Iterator for loop
		 */
		for (Iterator<String> i = list.iterator(); i.hasNext(); )
			System.out.println( i.next() );

		System.out.println( "\n\nAnd in sorted order:");
		Collections.sort(list);

		for (String s : list)
			System.out.println( s );
	}
}
